package com.ht.base.system.biz.convert;

import com.ht.base.system.common.pojo.bo.SysUserPostBO;
import com.ht.base.system.dao.domain.SysUserPostDO;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 类SysUserPostBeanUtil.java的实现描述：用户与岗位关联表工具类
 * 
 * @Author hdengxian
 * @Date 2023年05月26日
 */
public class SysUserPostBeanUtil {

    private SysUserPostBeanUtil(){
    }

    public static SysUserPostDO sysUserPostVOToDO(SysUserPostBO srcObj) {
        if (srcObj == null) {
            return null;
        }
        SysUserPostDO targetObj = new SysUserPostDO();
        /**id**/
        targetObj.setId(srcObj.getSysUserPostId());
        /**sysUserId**/
        targetObj.setSysUserId(srcObj.getSysUserId());
        /**sysPostId**/
        targetObj.setSysPostId(srcObj.getSysPostId());
        return targetObj;
    }

    public static SysUserPostBO sysUserPostDOToVO(SysUserPostDO srcObj) {
        if (srcObj == null) {
            return null;
        }
        SysUserPostBO targetObj = new SysUserPostBO();
        /**id**/
        targetObj.setSysUserPostId(srcObj.getId());
        /**sysUserId**/
        targetObj.setSysUserId(srcObj.getSysUserId());
        /**sysPostId**/
        targetObj.setSysPostId(srcObj.getSysPostId());
        return targetObj;
    }

    public static List<SysUserPostBO> doList2VOList(List<SysUserPostDO> doList) {
        List<SysUserPostBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) return boList;

        doList.stream().forEach(d -> boList.add(SysUserPostBeanUtil.sysUserPostDOToVO(d)));
        return boList;
    }

    public static List<SysUserPostDO> boList2DOList(List<SysUserPostBO> boList) {
        List<SysUserPostDO> doList = new ArrayList<>();
        if (CollectionUtils.isEmpty(boList)) return doList;

        boList.stream().forEach(b -> doList.add(SysUserPostBeanUtil.sysUserPostVOToDO(b)));
        return doList;
    }
}